/*
 * @Author: szx
 * @Date: 2022-03-28 13:56:17
 * @LastEditTime: 2022-03-28 13:58:08
 * @Description:
 * @FilePath: \leetcode\剑指offer\57\57.js
 */
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (nums, target) {
    let i = 0;
    j = nums.length - 1;
    while (i < j) {
        const num = nums[i] + nums[j];
        if (num == target) return [nums[i], nums[j]];
        else if (num > target) j--;
        else i++;
    }
    return [];
};
